﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SystemTime.cs" company="Donga CS">
//   2011
// </copyright>
// <summary>
//   SystemTime extension
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DONGACS.Common
{
    using System;

    /// <summary>
    /// SystemTime extension
    /// </summary>
    public static class SystemTime
    {
        /// <summary>
        /// Create DateTime now
        /// </summary>
        public static Func<DateTime> Now = () => DateTime.UtcNow;

        /// <summary>
        /// Get Month Start
        /// </summary>
        /// <param name="stDate">
        /// The st date.
        /// </param>
        /// <returns>
        /// The begining of DateTime value
        /// </returns>
        public static DateTime GetMonthStart(DateTime stDate)
        {
            return new DateTime(stDate.Year, stDate.Month, 1, 1, 0, 1, 1);
        }

        /// <summary>
        /// Get Month End
        /// </summary>
        /// <param name="stDate">
        /// The st date.
        /// </param>
        /// <returns>
        /// The ending of DateTime value
        /// </returns>
        public static DateTime GetMonthEnd(DateTime stDate)
        {
            return new DateTime(stDate.Year, stDate.Month, DateTime.DaysInMonth(stDate.Year, stDate.Month), 23, 59, 59);
        }
    }
}
